<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<h2>XML DOM Properties</h2>
<p>These are some typical DOM properties:</p>
<ul>
  <li>x.nodeName - the name of x</li>
  <li>x.nodeValue - the value of x</li>
  <li>x.parentNode - the parent node of x</li>
  <li>x.childNodes - the child nodes of x</li>
  <li>x.attributes - the attributes nodes of x</li>
</ul>
<p>Note: In the list above, x is a node object.</p>
<hr />
<h2>XML DOM Methods</h2>
<ul>
  <li>x.getElementsByTagName(<em>name</em>) - get all elements with a specified tag name</li>
  <li>x.appendChild(<em>node</em>) - insert a child node to x</li>
  <li>x.removeChild(<em>node</em>) - remove a child node from x</li>
</ul>
<p>Note: In the list above, x is a node object.</p>
<hr />
<h2>Example</h2>
<p>The JavaScript code to get the text from the first &lt;title&gt; element in books.xml:</p>
<p>txt=xmlDoc.getElementsByTagName(&quot;title&quot;)[0].childNodes[0].nodeValue</p>
<p>After the execution of the statement, txt will hold the value &quot;Everyday Italian&quot;</p>
<p>Explained:</p>
<ul>
  <li><strong>xmlDoc</strong> - the XML DOM object created by the parser.</li>
  <li><strong>getElementsByTagName(&quot;title&quot;)[0]</strong> - the first &lt;title&gt; element, nếu [1] thi no ko ra?</li>
  <li><strong>childNodes[0]</strong> - the first child of the &lt;title&gt; element (the text node)</li>
  <li><strong>nodeValue</strong> - the value of the node (the text itself)</li>
</ul>
<br />
</body>
</html>
